#include <iostream>
#include <cstdio>
using namespace std;
char s[105];
int main() {
	int n,k;
	cin>>n>>k;
	scanf("%s", s);
	int st,en;
	char ol, ne;
	for (int j=0; j<k; ++j) {
		scanf("%d %d %c %c", &st, &en, &ol, &ne);
//		cin>>st>>en>>ol>>ne;
		for (int i=st-1; i<=en-1; ++i) {
			if (s[i]==ol) s[i]=ne;
		}
	}
	printf("%s\n", s);
	return 0;
}
